package com.zhuiyun.educations.api.sysroleback.service.impl;

import com.zhuiyun.educations.api.sysroleback.entiy.SysRoleBack;
import com.zhuiyun.educations.api.sysroleback.mapper.SysRoleBackMapper;
import com.zhuiyun.educations.api.sysroleback.service.SysRoleBackService;
import com.zhuiyun.educations.util.pageUtil.MybatisPageHelper;
import com.zhuiyun.educations.util.pageUtil.PageRequest;
import com.zhuiyun.educations.util.pageUtil.PageResult;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

/**
 * @ClassName SysRoleBackServiceImpl
 * @Description TODO
 * @Author MJL
 * @Date 2023/6/15 20:44
 **/
@Service
public class SysRoleBackServiceImpl implements SysRoleBackService {
    @Resource
    SysRoleBackMapper sysRoleBackMapper;

    /**
    * @Author MJL
    * @Description todo 角色表全查
    * @Date 2023/6/15 21:01
    * @Return  * @param null
    */
    @Override
    public PageResult SysRoleList(SysRoleBack sysRoleBack, PageRequest pageRequest) {
        MybatisPageHelper.startPage(pageRequest);
        PageResult pageResult = MybatisPageHelper.getPageResult(sysRoleBackMapper.SysRoleList(sysRoleBack));
        return pageResult;
    }

    /**
    * @Author MJL
    * @Description todo 角色表添加
    * @Date 2023/6/16 14:21
    * @Return  * @param null
    */
    @Override
    public int SysRoleAdd(SysRoleBack sysRoleBack) {
        Date date = new Date();
        sysRoleBack.setCreateTime(date);
        sysRoleBack.setDelFlag(0);
        return sysRoleBackMapper.SysRoleAdd(sysRoleBack);
    }

    /**
    * @Author MJL
    * @Description todo 角色表删除
    * @Date 2023/6/21 15:50
    * @Return  * @param null
    */
    @Override
    public int SysRoleUpdateDelete(Integer id) {
        return sysRoleBackMapper.SysRoleUpdateDelete(id);
    }

    /**
    * @Author MJL
    * @Description todo 角色表修改
    * @Date 2023/6/21 16:05
    * @Return  * @param null
    */
    @Override
    public int SysRoleUpdate(SysRoleBack sysRoleBack) {
        Date date = new Date();
        sysRoleBack.setUpdateTime(date);
        return sysRoleBackMapper.SysRoleUpdate(sysRoleBack);
    }

    /**
    * @Author MJL
    * @Description todo 角色表分配权限
    * @Date 2023/6/23 14:50
    * @Return  * @param null
    */
    @Override
    public int SysRoleAssignment(SysRoleBack sysRoleBack) {
        return sysRoleBackMapper.SysRoleAssignment(sysRoleBack);
    }

}
